/**
 * Ready函数
 */
$(function() {
	bindEscEvent();
});

/**
 * 弹出静态生成结果窗口
 */
function openResultWindow(msg) {
	var options = {
		width: 375,
		height: 150,
		showType: "show",
		showSpeed: 500,
		title: "操作报告",
		msg: "<font style=\"font-size: 13px;color:red;\">" + msg + "</font>",				
		timeout: 0
	};
	$.messager.show(options);
}

/**
 * 关闭结果窗口
 */
function closeResultWindow() {
	$("div.window .window-header .panel-tool-close").click();
}

/**
 * 绑定ESC事件
 */
function bindEscEvent() {
	$(window).keydown(function(event) {
	   if (event.keyCode == 27) {
		   closeResultWindow();
	   }
	});
}

/**
 * 静态生成HTML
 */
function generateHtml(rowIndex, obj) {
	var rowData = $(datagrid_id).datagrid("getRows")[rowIndex];	
	$(obj).hide().parent().siblings("span").show();
	
	$.ajax({
		url:appPath+'/cms/staticGenerate_getHtml.do',
		type:"post",
		data:'&pageStyle.pageId=' + $.trim(rowData.pageId),
		success:function(msg){
			$(obj).show().parent().siblings("span").hide();
			openResultWindow(msg);
		},
		error:function(XMLHttpRequest, textStatus, errorThrown){
			$(obj).show().parent().siblings("span").hide();
			openResultWindow("请求失败，请稍后重试！");
		}
	});
}




